home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 January / PCWorld_2007-01_cd.bin / v cisle / autoit / autoit-v3.2.0.1-setup.exe / Examples / Helpfile / Func.au3 < prev    next >
Text File  |  2006-06-17  |  717b  |  32 lines

  1. ; Sample script with three user-defined functions
  2. ; Notice the use of variables, ByRef, and Return
  3.  
  4. $foo = 2
  5. $bar = 5
  6. msgBox(0,"Today is " & today(), "$foo equals " & $foo)
  7. swap($foo, $bar)
  8. msgBox(0,"After swapping $foo and $bar", "$foo now contains " & $foo)
  9. msgBox(0,"Finally", "The larger of 3 and 4 is " & max(3,4))
  10. Exit
  11.  
  12. Func swap(ByRef $a, ByRef $b)  ;swap the contents of two variables
  13.     Local $t
  14.     $t = $a
  15.     $a = $b
  16.     $b = $t
  17. EndFunc
  18.  
  19. Func today()  ;Return the current date in mm/dd/yyyy form
  20.     return (@MON & "/" & @MDAY & "/" & @YEAR)
  21. EndFunc
  22.  
  23. Func max($x, $y)  ;Return the larger of two numbers
  24.     If $x > $y Then
  25.         return $x
  26.     Else
  27.         return $y
  28.     EndIf
  29. EndFunc
  30.  
  31. ;End of sample script
  32.